#pragma once
class CMeasureCmd
{
  friend class boost::serialization::access;

public:
  CMeasureCmd(void);
  CMeasureCmd(const tstring& Name, const tstring& Cmd);
  CMeasureCmd(const tstring& Name, const tstring& Cmd, const tstring& Serial);
  ~CMeasureCmd(void);

public:
  void Reset(void);
  long Process(CWnd *view, CommandSource cmd_source);

public:
  long AddStation(const tstring& Station);
  long DeleteStation(const tstring& Station);
  void ClearStations(void) { stations_.clear(); }

  long AddItem(const tstring& Item);
  long DeleteItem(const tstring& Item);
  void ClearItems(void) { items_.clear(); }
  void MoveItemUp(int index);
  void MoveItemDown(int index);
  int FindItem(const tstring& itemName);
  void SetItemName(int itemPos, const tstring& itemName);

  long AddIntermediate(const tstring& Intermediate);
  long DeleteIntermediate(const tstring& Intermediate);
  void ClearIntermediates(void) { intermediates_.clear(); }

public:
  const tstring& Name(void) const { return name_; }
  void set_name(const tstring& val) { name_ = val; }

  const tstring& cmd(void) const { return cmd_; }
  void set_cmd(const tstring& val) { cmd_ = val; }

  const tstring& serial(void) const { return serial_; }
  void set_serial(const tstring& val) { serial_ = val; }

  int num_stations(void) const { return static_cast<int>(stations_.size()); }
  const tstring& station(int index) const { return stations_[index]; }

  int num_items(void) const { return static_cast<int>(items_.size()); }
  const tstring& item(int index) const { return items_[index]; }

  int num_intermediates(void) const { return static_cast<int>(intermediates_.size()); }
  const tstring& intermediate(int index) const { return intermediates_[index]; }

private:
  tstring name_;
  tstring cmd_;
  tstring serial_;
  std::vector<tstring> stations_;
  std::vector<tstring> items_;
  std::vector<tstring> intermediates_;

  template<class Archive>
  void serialize(Archive &ar, const unsigned int version)
  {
    using boost::serialization::make_nvp;
    ar & make_nvp("name",             name_);
    ar & make_nvp("command",          cmd_);
    ar & make_nvp("serial",           serial_);
    ar & make_nvp("stations",         stations_);
    ar & make_nvp("measure_items",    items_);
    ar & make_nvp("intermediates",    intermediates_);
  }
};

